/**
 * @(#)ProcessInstanceHelper.java Sep 2, 2009
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package com.wilmar.process.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 流程实例辅助对象
 * 
 * @author MaKuBEX Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class ProcessInstanceHelper implements Serializable {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = 275112830089459569L;

	private User starter;
	private User lastestOperator;
	private String lastestTaskInstanceId;
	private String processDefinitionId;
	private String processDefinitionKey;
	private String processDefinitionName;
	private List<User> allOperators;
	private Map<String, User> taskInstanceAssignMap;

	private String ownerInstanceExid;
	private String rootInstanceExid;

	/**
	 * 增加一个参与人到参与人列表中
	 * 
	 * @param operator
	 *            参与人
	 */
	public void addOperator(User operator) {
		if (this.allOperators == null)
			this.allOperators = new ArrayList<User>();
		this.allOperators.add(operator);
	}

	/**
	 * 增加一条接收人对应信息
	 * 
	 * @param taskName
	 *            任务名称
	 * @param assign
	 *            接收人信息
	 */
	public void addAssignInfo(String taskName, User assign) {
		if (this.taskInstanceAssignMap == null)
			this.taskInstanceAssignMap = new HashMap<String, User>();
		this.taskInstanceAssignMap.put(taskName, assign);
	}

	/**
	 * 删除一个参与人
	 * 
	 * @param index
	 *            参与人参与的序号
	 */
	public void removeOperator(Integer index) {
		if (this.allOperators != null)
			this.allOperators.remove(index);
	}

	/**
	 * 删除一个参与人
	 * 
	 * @param operator
	 *            参与人信息
	 */
	public void removeOperator(User operator) {
		if (this.allOperators != null)
			this.allOperators.remove(operator);
	}

	/**
	 * @return the lastestOperator
	 */
	public User getLastestOperator() {
		return lastestOperator;
	}

	/**
	 * @return the starter
	 */
	public User getStarter() {
		return starter;
	}

	/**
	 * @param lastestOperator
	 *            the lastestOperator to set
	 */
	public void setLastestOperator(User lastestOperator) {
		this.lastestOperator = lastestOperator;
	}

	/**
	 * @param starter
	 *            the starter to set
	 */
	public void setStarter(User starter) {
		this.starter = starter;
	}

	/**
	 * @return the processDefinitionId
	 */
	public String getProcessDefinitionId() {
		return processDefinitionId;
	}

	/**
	 * @param processDefinitionId
	 *            the processDefinitionId to set
	 */
	public void setProcessDefinitionId(String processDefinitionId) {
		this.processDefinitionId = processDefinitionId;
	}

	/**
	 * @return the processDefinitionKey
	 */
	public String getProcessDefinitionKey() {
		return processDefinitionKey;
	}

	/**
	 * @param processDefinitionKey
	 *            the processDefinitionKey to set
	 */
	public void setProcessDefinitionKey(String processDefinitionKey) {
		this.processDefinitionKey = processDefinitionKey;
	}

	/**
	 * @return the processDefinitionName
	 */
	public String getProcessDefinitionName() {
		return processDefinitionName;
	}

	/**
	 * @param processDefinitionName
	 *            the processDefinitionName to set
	 */
	public void setProcessDefinitionName(String processDefinitionName) {
		this.processDefinitionName = processDefinitionName;
	}

	/**
	 * @return the lastestTaskInstanceId
	 */
	public String getLastestTaskInstanceId() {
		return lastestTaskInstanceId;
	}

	/**
	 * @param lastestTaskInstanceId
	 *            the lastestTaskInstanceId to set
	 */
	public void setLastestTaskInstanceId(String lastestTaskInstanceId) {
		this.lastestTaskInstanceId = lastestTaskInstanceId;
	}

	/**
	 * @return the allOperators
	 */
	public List<User> getAllOperators() {
		if (this.allOperators == null)
			this.allOperators = new ArrayList<User>();
		return allOperators;
	}

	/**
	 * @param allOperators
	 *            the allOperators to set
	 */
	public void setAllOperators(List<User> allOperators) {
		this.allOperators = allOperators;
	}

	/**
	 * @return the taskInstanceAssignMap
	 */
	public Map<String, User> getTaskInstanceAssignMap() {
		return taskInstanceAssignMap;
	}

	/**
	 * @param taskInstanceAssignMap
	 *            the taskInstanceAssignMap to set
	 */
	public void setTaskInstanceAssignMap(Map<String, User> taskInstanceAssignMap) {
		this.taskInstanceAssignMap = taskInstanceAssignMap;
	}

	/**
	 * @return the ownerInstanceExid
	 */
	public String getOwnerInstanceExid() {
		return ownerInstanceExid;
	}

	/**
	 * @param ownerInstanceExid
	 *            the ownerInstanceExid to set
	 */
	public void setOwnerInstanceExid(String ownerInstanceExid) {
		if (this.rootInstanceExid == null)
			this.rootInstanceExid = ownerInstanceExid;
		this.ownerInstanceExid = ownerInstanceExid;
	}

	/**
	 * @return the rootInstanceExid
	 */
	public String getRootInstanceExid() {
		return rootInstanceExid;
	}

}